<?php
	//Xay dung tim kiem
	$ssFilter 		= $this->arrParam['ssFilter'];
	$page = '';
	if(isset($this->arrParam['page'])){
		$page = '/page/' . $this->arrParam['page'];
	}
	$id_kh = '';
	if(!empty($this->arrParam['id_kh'])){
		$id_kh = '/id_kh/' . $this->arrParam['id_kh'];
	}
	
	$action_link 		= $this->baseUrl($this->currentController . '/filter/type/order' . $id_kh);
	$lblDiemdauvao 		= $this->cmsLinkSort('Điểm đầu vào', 'hd.diemdauvao', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblDiemdaura 		= $this->cmsLinkSort('Điểm đầu ra', 'hd.diemdaura', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblDiemgiuaky 		= $this->cmsLinkSort('Điểm giữa kỳ', 'hd.diemgiuaky', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblDiemgiaovien 	= $this->cmsLinkSort('Điểm giáo viên', 'hd.diemgiaovien', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblDiemcoach 		= $this->cmsLinkSort('Điểm cho coach', 'hd.diemcoach', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblDiemlophoc 		= $this->cmsLinkSort('Điểm lớp học', 'hd.diemlophoc', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblSobuoidiemdanh 	= $this->cmsLinkSort('Số buổi điểm danh', 'hd.sobuoidiemdanh', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblKhachhangName	= $this->cmsLinkSort('Tên khách hàng', 'hd.khachhang_name', $ssFilter, $this->imgUrl . '/admin',$action_link);
	$lblNhanvienName	= $this->cmsLinkSort('Người quản lý', 'nhanvien_name',  $ssFilter, $this->imgUrl. '/admin', $action_link);	
	$lblLophoc			= $this->cmsLinkSort('Tên lớp', 'hd.id_lophoc',  $ssFilter, $this->imgUrl. '/admin', $action_link);	
	$lblMahocvien		= $this->cmsLinkSort('Mã học viên', 'hd.khachhang_code',  $ssFilter, $this->imgUrl. '/admin', $action_link);
	
	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort txtsearch'));
	
	//---------------------GROUP SELECTBOX --------------------//
	$this->slbKhoahoc[0] = '- Chọn khóa học -';
	$linkSlbKhoahoc = $this->baseUrl($this->currentController . '/filter/type/id_khoahoc' . $id_kh);
	$selectKhoahoc = $this->formSelect('id_khoahoc', $ssFilter['id_khoahoc'], array('style'=>'width:120px;','onchange'=>"OnSubmitForm('" .$linkSlbKhoahoc ."')"), $this->slbKhoahoc);

	$this->slbLopHoc[0] = '- Chọn lớp học -';
	$linkSlbLopHoc = $this->baseUrl($this->currentController . '/filter/type/id_lophoc' . $id_kh);
	$selectLopHoc = $this->formSelect('id_lophoc', $ssFilter['id_lophoc'], array('style'=>'min-width:100px;','onchange'=>"OnSubmitForm('" .$linkSlbLopHoc ."')"), $this->slbLopHoc);
	
	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1' . $id_kh);
	$btnSearch = $this->formButton('search-now','Tìm', array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkSearch . "')"));
	
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0' . $id_kh);
	$btnResetSearch = $this->formButton('clear-keywords','Xóa',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkResetSearch ."')"));
	
	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;

	$linkBlocks = $this->baseUrl($this->currentController . '/filter/type/blocks');
	$slbBlocks = array(
			'0' => '- Lựa chọn -',
			'nohocphi'=> 'Còn nợ học phí',
			'chuavaolop'=> 'Chưa xếp vào lớp',
	);
	$selectBlocks = $this->formSelect('blocks',$ssFilter['blocks'],array('style'=>'width:110px;', 'onchange'=>"OnSubmitForm('" .$linkBlocks ."')"),$slbBlocks);
	
	//$strSearchRight = $selectKhoahoc . ' ' . $selectLopHoc ;
	$strSearchRight = $selectKhoahoc . ' ' . $selectLopHoc . ' ' . $selectBlocks;
?>

<div class="left_content">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/left.php');?>
</div>

<div class="right_content">
	<div class="appContent">
	
	<form action="" method="post" name="appForm">
		<?php echo $this->render($this->arrParam['controller'] . '/toolbar/index.php');?>
		<?php
			if($this->arrParam['save'] == 'ok'){
				echo '<div class="thongbaoThanhCong goc5">Xử lý dữ liệu thành công</div>';
			} 
		?>
		<div class="formList goc5">
			<div class="appTop goct5">
				<div class="block_filter">
					<div class="fl">
						<div class="listSearch">
							<?php echo $strSearch; ?>
							<div class="clr"></div>			
						</div>
					</div>
					<div class="fr">
						<div class="listSelect">
							<?php echo $strSearchRight; ?>
						</div>
					</div>
					<div class="clr"></div>
				</div>
			</div>
			<div class="appBody">
				<table class="tblList">
					<tr>
						<th width="90">Mã học viên</th>
						<th width="200">Tên Học viên</th>
						<th width="80"><?php echo $lblDiemdauvao;?> <span class="note"></span></th>
						<th width="80"><?php echo $lblDiemgiuaky;?> <span class="note"></span></th>
						<th width="80"><?php echo $lblDiemdaura;?> <span class="note"></span></th>
						<th width="80"><?php echo $lblDiemgiaovien;?> <span class="note"></span></th>
						<th width="80"><?php echo $lblDiemcoach;?> <span class="note"></span></th>
						<th width="80"><?php echo $lblDiemlophoc;?> <span class="note"></span></th>
						
						<th width="80"><?php echo $lblSobuoidiemdanh;?> <span class="note"></span></th>
						<th width="100"> <?php echo $lblLophoc;?></th>
						<th width="60">Thao tác</th>
					</tr>
					<?php 
						foreach ($this->Items as $key => $val) {
							$id 			= $val['id'];
							$code 			= strtoupper($val['khachhang_code']) ;
							$khachhang_name = $val['khachhang_name'];
							$hd_thanhtien	= $val['hd_thanhtien'];
							$hd_sotienno	= $val['hd_sotienno'];
							$hd_diemdauvao	= $val['diemdauvao'];
							$hd_diemgiuaky	= $val['diemgiuaky'];
							$hd_diemdaura	= $val['diemdaura'];
							$hd_diemgiaovien	= $val['diemgiaovien'];
							$hd_diemcoach	= $val['diemcoach'];
							$hd_diemlophoc	= $val['diemlophoc'];
							
							$hd_sobuoidiemdanh	= $val['sobuoidiemdanh'];
							
							
							
							$nhanvien_name 	= $val['nhanvien_name'];
							if(!empty($val['nhanvien_alias'])) {
								$nhanvien_name = $val['nhanvien_name'] . ' (' . $val['nhanvien_alias'] . ')';
							}
							$lophoc_name 	= $val['lophoc_name'];
							
							$linkInfo		= $this->baseUrl($this->currentController . '/info' . '/id_kh/' . $val['id_kh'] . '/id/' . $id . $page);
							$btnInfo		= $this->cmsIconButton('Xem thông tin', $this->imgUrl . '/admin/icon_info.png', $linkInfo);
							
							$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id . $page);
							$btnEdit		= $this->cmsIconButton('Sửa điểm', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
							$btnAdd			= $this->cmsIconButton('', $this->imgUrl . '/menu/icon-16-maintenance.png', 'javascript::void(0)', array('onclick' => 'showFunction('. $id .')'));
								
							$linkhistory	= $this->baseUrl('khachhang/admin-history/index/id/' . $id);
							$linkclass	 	= $this->baseUrl('khachhang/admin-history/hoctap/id/' . $id);
							$divAdd			= '<div class="blockFunction selectFunction'.$id .'">
												<ul>
												<li><a target="_blank" href="' . $linkEdit . '" class="icon-16-new">Sửa điểm </a></li>
												<li><a target="_blank" href="' . $linkhistory . '" class="icon-16-new">Lịch sử chăm sóc KH</a></li>
												<li><a target="_blank" href="' . $linkclass . '" class="icon-16-new">Lịch sử học tập</a></li>
												
												</ul>
												</div>';
												
							$strIconButton 	= $btnAdd.''.$divAdd ;
								
							$cid 			= $this->formCheckbox('cid[]',$val['id']);
					?>
						<tr <?php if (($id % 2) != 0) echo "class='row1'"; ?>>
							<td align="center"><?php echo $code; ?></td>
							<td align="left"><?php echo $khachhang_name; ?> <p class="smallsub">Người quản lý: <?php echo $nhanvien_name;?></p></td>
							<td align="right"><?php echo $hd_diemdauvao; ?></td>
							<td align="right"><?php echo $hd_diemgiuaky; ?></td>
							<td align="right"><?php echo $hd_diemdaura; ?></td>
							<td align="right"><?php echo $hd_diemgiaovien; ?></td>
							<td align="right"><?php echo $hd_diemcoach; ?></td>
							<td align="right"><?php echo $hd_diemlophoc; ?></td>
							<td align="center"><?php echo $hd_sobuoidiemdanh; ?></td>
							<td align="center"><?php echo $lophoc_name; ?></td>
							<td align="center">
								<div style="position:relative">
									<?php echo $strIconButton; ?>
								</div>
							
							</td>
						</tr>
					<?php
						}
					?>					
				</table>
			</div>
			<div class="appBottom">
				<div class="pagination">
					<?php
						$currentUrl = $this->baseUrl($this->currentController . '/index');
						echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml', array('currentUrl'=>$currentUrl)); 
					?>
				</div>
			</div>
		</div>
	</form>
	</div>
</div>
<div class="clr"></div>	
<script type="text/javascript">
	function showFunction(i){
		$('.selectFunction' + i).show();
		$('body').append('<div id="overlay" style="width:100%; height:100%; top: 0; left: 0; z-index: 499; position: fixed;" onclick="hideOption()"></div>');
	}
	function hideOption(){
		$('.blockFunction').hide();
		$('#overlay').remove();
	}
</script>
